<template>
	<section>
		<!--start  面包屑-->
		<div class="location">
			<el-breadcrumb separator="/">
				<el-breadcrumb-item :to="{path:'/index'}">首页</el-breadcrumb-item>
				<el-breadcrumb-item :to="{path:'/goods'}">商品</el-breadcrumb-item>
				<el-breadcrumb-item>商品入库</el-breadcrumb-item>
			</el-breadcrumb>
			<!--start 右侧帮助组件    可选！！-->
			<help-components>
				<span slot="headtext">入库登记列表</span>
				<p slot="headDescText">入库登记列表</p>
				<div slot="helpContentWrap">
				</div>
			</help-components>
			<!--end 右侧帮助组件-->
		</div>
		<!--end  面包屑-->
		<!--start content-->
		<div class="content" ref="content">

			<!--start 普通搜索-->
			<div class="public_th clearfix" >
				<!--<div class="slideBtn fl" >
					<el-select v-model="stockCheckinQb.warehouseCode" @change="generalSearch_ok" placeholder="全部仓库">
						<el-option label="全部仓库" value="">
							<span style="font-size:12px ;">全部仓库</span>
						</el-option>
						<el-option v-for="item in stockCheckinQb.options"
							:key="item.warehouseCode"
							:label="item.warehouseName"
							:value="item.warehouseCode">
						</el-option>
					</el-select>
				</div>-->
				<div class="slideBtn fl textR">
					<el-select v-model="stockCheckinQb.ddlistCode" @change="ddlist_generalSearch_ok" placeholder="全部类型">
						<el-option label="全部类型" value="">
							<span style="font-size:12px ;">全部类型</span>
						</el-option>
						<el-option v-for="item in stockCheckinQb.options"
							:key="item.ddlistCode"
							:label="item.ddlistName"
							:value="item.ddlistCode">
						</el-option>
					</el-select>
				</div>
				<div class="public_th_left fl">
					<div class="fl">
						<div class="search_input">
							 <el-date-picker
						      v-model="stockCheckinQb.createDate"
						      type="daterange"
						      @change="generalSearch_ok"
						      placeholder="选择日期范围">
						    </el-date-picker>
						</div>
					</div>
				</div>
				<div class="public_th_right fr">
					<!--<a>导入</a>
					<a>导出</a>-->
					<router-link to="/goods/stockCheckinAdd" style="background: #13c19f;color: #fff;border: 0;">新增</router-link>
				</div>
			</div>
			<!--end 普通搜索-->
			<!--start 表格-->
			<div class="table contentBodyCon content_table_list" :class="{beforeNone:stockCheckinSet.list.length!='0'}">
				<el-table
					ref="stockCheckinRows"
					:data="stockCheckinSet.list"
					style="width: 100%;  z-index: 10;"
					@sort-change="vFun_sort"
					:max-height="vue_tableHeight" >
					<el-table-column prop="checkinCode" label="单号" sortable="custom" min-width="120">
						<!--start 可点击的项  可选！！-->
						<template scope="scope">
							<span class="canClickText" @click="row_goDetail(scope.row)" v-html="scope.row.checkinCode"></span>
						</template>
						<!--end 可点击的项-->
					</el-table-column>
					<el-table-column prop="checkinTypeValue" label="入库类型" min-width="120"></el-table-column>
					<el-table-column prop="warehouseName" sortable="custom" label="所属仓库" min-width="120"></el-table-column>
					<el-table-column prop="createOpName" sortable="custom" label="制单人名称" min-width="120"></el-table-column>
					<el-table-column prop="createDateStr" sortable="custom" label="入库日期" min-width="120"></el-table-column>
					<!-- add more column header -->

					<el-table-column prop="" label="" fixed="right" width="60" >
						<template scope="scope">
							<el-popover trigger="hover" placement="bottom">
								<p class="popover_p" style="cursor: pointer;" @click="row_goDetail(scope.row)">
									<em class="iconfont">&#xe759;</em>明细
								</p>
								<div slot="reference" style="text-align: center;">
									<em class="iconfont tab_hover">&#xe607;</em>
								</div>
							</el-popover>
						</template>
					</el-table-column>
				</el-table>
			</div>
			<!--end 表格-->
			<div class="block fr">
				<el-pagination
					@size-change="page_onPageSizeChange"
					@current-change="page_onCurPageChange"
					:current-page="parseInt(stockCheckinSet.pageTools.pageNo)"
					:page-sizes="stockCheckinSet.pageTools.pageSizeOptions"
					:page-size="parseInt(stockCheckinSet.pageTools.pageSize)"
					:total="parseInt(stockCheckinSet.pageTools.recordCount)"
					layout="total, prev, pager, next, sizes,jumper">
				</el-pagination>
			</div>
		</div>
		<!--end content-->
	</section>
</template>

<script>
	/*
	 1.引入的组件、文件等，优先写在顶部。
	 2.组件的选项编写顺序按照先string再obj再function，详细如下：
	 	1):el=>name=>template
	 	2):components=>watch=>filters=>computed=>props=>directives=>propsData=>parent=>mixins=>delimiters=>functional=>methods
	 	3):render=>data=>extends=>生命周期钩子
	 * */
	import helpComponents from '../../../components/help/help'    //引入右侧帮助组件 可选！！
	export default {
		components:{helpComponents},
		data() {
			return {
				/* start 全局变量定义 */
//				vue_advSearch_showDialog:false,  //是否启用高级搜索功能
//				vue_advSearch_enable:false,  //是否显示高级搜索窗口
				vue_tableHeight:500,  //表格高度
				vue_generalSearch_ddtypeCode:"00100000031",  //状态的唯一业务码
//				vue_row_selectCount:0,  //选择的row数
//				vue_row_checkinCodeStr:"",  //选中的row

					//table数据
				stockCheckinSet: {
					"list":[],  //数据列表
					"page":{},	//分页数据
					"sumInfo":{}, //汇总信息
				},
					/*--查询条件--*/
				stockCheckinQb:{
					"dataBillstate":"",  //客户状态
					"fullTextFilterStr":"",  //查询关键词
					ddlistCode: '',						//级别下拉
					options:[],
					createDate:'',
					"orderStr":""
				},
				/* end 全局变量定义 */
			}
		},
		methods: {
	    	vFun_sort(type){
	    		if(type.order==='ascending'){
	    			this.stockCheckinQb.orderStr=type.prop
	    		}else if(type.order==='descending'){
	    			this.stockCheckinQb.orderStr=type.prop +' desc'
	    		}else{
	    			this.stockCheckinQb.orderStr=''
	    		};
	    		this.queryByPage();
	    	},
			/* start 页面交互方法 */
			query_ddtypeListAll(code){
				this.axios({
					method: 'post',
					url: "/v3/system/ddlists/"+code+"/listAll",
					data:{

					}
				}).then((res) => {
					this.stockCheckinQb.options = res.data.list;
				}).catch((err)=>{
					this.Public.openError(this,err.response.data);
			  	});
			},
				//跳转编辑
			row_goUpdate(data){
				localStorage.setItem("checkinCode",data.checkinCode);
				this.$router.push({path:"/stockCheckinUpdate"});
			},
				//查看详情
			row_goDetail(data){
				localStorage.setItem("checkinCode",data.checkinCode);
				this.$router.push({path:"/goods/stockCheckinDetail"});
			},
				//普通搜索 关键字
			generalSearch_ok(){
				this.stockCheckinSet.pageTools.pageNo=1;
				this.queryByPage();
			},
				//下拉搜索
			ddlist_generalSearch_ok(){
				this.stockCheckinQb.dataBillstate=this.stockCheckinQb.ddlistCode;
				this.stockCheckinSet.pageTools.pageNo=1;
				this.queryByPage();
			},
				//查table数据
			queryByPage(){
				this.axios({
					method: 'post',
					url: "/v3/stock/checkins/list",
					data:{
						"offset":(this.stockCheckinSet.pageTools.pageNo-1)*this.stockCheckinSet.pageTools.pageSize,
						"limit":this.stockCheckinSet.pageTools.pageSize,
						"supStartDate":this.stockCheckinQb.createDate[0],
						"supEndDate":this.stockCheckinQb.createDate[1],
						"checkinType":this.stockCheckinQb.dataBillstate,
						"orderStr":this.stockCheckinQb.orderStr,
					}
				}).then((res) => {
					this.stockCheckinSet.list = res.data.list;
					this.stockCheckinSet.pageTools = res.data.pageTools;
					this.stockCheckinSet.pageTools.pageSizeOptions = JSON.parse(this.stockCheckinSet.pageTools.pageSizeOptions);
					this.stockCheckinSet.sumInfo = res.data.sumInfo;

				}).catch((err)=>{
					this.Public.openError(this,err.response.data);
			  	});
			},
				//pageSize每页条数变化时的fn
			page_onPageSizeChange(val) {
				this.stockCheckinSet.pageTools.pageSize = val;
				this.queryByPage();
			},
				//pageNo当前页码变化时的fn
			page_onCurPageChange(val) {
				this.stockCheckinSet.pageTools.pageNo = val;
				this.queryByPage();
			},

		},
		created(){
			this.stockCheckinSet.pageTools = this.$store.state.page;
			//请求客户列表
			this.queryByPage();
			this.query_ddtypeListAll(this.vue_generalSearch_ddtypeCode);
		},
		mounted() {
			//动态设置高度
			this.$refs.content.style.height = (document.documentElement.clientHeight - 124)+"px";
			this.vue_tableHeight = document.documentElement.clientHeight - 240;
		},
	}
</script>

<style scoped>
	/* start  面包屑 */
	.location {padding: 3px 0 15px 0;}
	/* end  面包屑 */
	/* start content */
	.content {position: relative;background: #fff;padding: 15px;overflow-y: auto;font-family: "微软雅黑";}
		/* start 高级搜索 */
	.modal_backdrop {position: fixed;top: 0;right: 0;bottom: 0;left: 0;z-index: 80;background-color: rgba(240, 240, 240, 0.2);}
	.specific_search {position: absolute;width: 100%;top: 0;left: 0;padding: 30px;z-index: 1005;background: #fff;box-sizing: border-box;box-shadow: 0 0 10px #ccc;}
	.search_title {font-size: 16px;border: 0;color: #415161;}
	.form {width: 450px;margin: 20px 0;background: #fff;text-align: right;}
	.form li {margin-top: 15px;}
	.form input {width: 350px;height: 32px;border: 0;}
	.form div {display: inline-block;position: relative;width: 358px;height: 34px;border-radius: 4px;text-indent: 5px;margin-left: 12px;}
	.form li:first-child div {border: 1px solid rgb(191, 212, 217);}
	.form li:first-child div input {border-radius: 4px;}
	.search_btn {margin-top: 20px;}
	.search_handle {margin-left: -6px;height: 36px;line-height: 36px;}
	.search_handle em {font-size: 14px;}
	.search_handle a {margin-right: 20px;cursor: pointer;color: #768696;}
	.search_handle a:hover {color: #03B8CC;}
	.search_handle {margin-left: 10px;}
		/* end 高级搜索 */
		/* start 批量操作 */
	.batch_handle {margin-left: -6px;height: 36px;line-height: 36px;}
	.batch_handle em {font-size: 14px;}
	.batch_handle a {margin-right: 20px;cursor: pointer;color: #768696;}
	.batch_handle a:hover {color: #03B8CC;}
		/* end 批量操作 */
		/* start 普通搜索 */
	.public_th {position: relative;min-width: 750px;z-index: 100;}
	.public_th_left span.search_openBtn {display: block;position: relative;height: 36px;margin-right: 10px;padding-right: 0px;line-height: 36px;color:#93a6b7;z-index: 100;cursor: pointer;}
	.slideBtn {line-height: 36px;margin-right: 26px;}
	.slideBtn>div>span{display: block;cursor: pointer;}
	.search_input input {display: block;float: left;width: 400px;height: 34px;font-size: 12px;border: 0;margin-left: 20px;}
	.search_input {float: left;width: 450px;margin-right: 10px;cursor: pointer;}
	.search_input:hover {border-color:#13C19F;transition: 1s;}
	.search_input i {background: url('../../../img/sousuo.png') no-repeat; height: 20px;width: 20px;display: inline-block;position: relative;top: 7px;right: 5px;cursor: pointer;}
	.public_th_right a {display: block;float: left;width: 80px;height: 32px;margin-left: 10px;box-sizing: border-box;text-decoration: none;text-align: center;line-height: 32px;border-radius: 30px;border: 1px solid #cdd9e6;cursor: pointer;}
		/* end 普通搜索 */
		/* start 表格 */
	.table {margin-top: 15px;}
	.table th {height: 50px;}
	.el-table th>.cell {width: 100%;word-wrap: normal;text-overflow: ellipsis;line-height: 20px;box-sizing: border-box;font-weight: normal !important;font-size: 14px;}
	.el-table {font-size: 12px !important;font-weight: normal !important;}
	.el-table--fit {border-left: 0;}
	.popover_p {text-indent: 10px;line-height: 30px;}
	.popover_p em {position: relative;top: 2px;margin-right: 3px;}
	.popover_p:hover {background: #eef1f9;color: #03B8CC;}
	.tab_hover {color: #b7c6d6;cursor: pointer;}
	.canClickText {cursor: pointer;}
	.canClickText:hover {color:#03B8CC;}
		/* end 表格 */
		/* start page */
	.block {margin: 15px;}
		/* end page */
	/* end content */
	/* start transition */
	.fade-enter,.fade-leave-active {opacity: 0}
	.fade-enter-active,.fade-leave-active {transition: .4s;}
	/* end transition */
	.search_input .el-date-editor--daterange.el-input{
		width: 350px;
	}
</style>
